package Server;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Vector;

public class Server {
	private static ChatRooms cr;

	public static void main(String[] args) {
		ServerSocket server = null;
		try {
			server = new ServerSocket(30005);
		} catch (IOException e) {
			System.out.println(e);
			System.exit(1);
		}

		cr = new ChatRooms(server);

		while (true) {
			Socket socket = null;
			try {
				socket = server.accept();
			} catch (IOException e) {
				System.out.println(e);
				System.exit(1);
			}

			System.out.println("Socket accpeted! Adress to socket: "
					+ socket.getInetAddress().toString());

			ClientRepresentative c = new ClientRepresentative(server, socket,
					cr);
			c.start();

		}

	}
}
